package com.atguigu.yygh.msm.receiver;

import com.atguigu.yygh.msm.service.MsmService;
import com.atguigu.yygh.vo.msm.MsmVo;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @author 孔德成
 * @slogan 致敬大师，致敬未来的你
 * @date 2021/9/14 2:09 上午
 * @desc 短信队列消息的处理者
 */
@Component
@RabbitListener(queues = "yygh.msm.success")
public class SmsReceiver {
    private final MsmService msmService;

    public SmsReceiver(MsmService msmService) {
        this.msmService = msmService;
    }

    /**
     * 从队列中接收到消息后，发送一条短信
     *
     * @param msmVo
     */
    @RabbitHandler
    public void send(MsmVo msmVo) {
        msmService.sendMq(msmVo);
    }
}
